A few basic rules keep the main server thread and the multi-rendering threads from deadlocking or colliding with each other.
This creates certain implementation requirements for extension request processing functions. For example, in the OpenGL extension the main X server thread decodes protocol requests, looks up X resource IDs, and either increments reference counts or copies data from X internal structures so that a structure will never disappear while it is being referenced in a rendering thread. Even when a client connection closes, some data structures cannot be freed immediately. A special interface is provided so that the rendering thread can perform clean-up operations after the client connection is closed; only after the rendering thread clean-up action is done can the main X server thread be allowed to free the client's resources.